<?php
/**
 * Project:	BBCodeAdvanced
 * File:	index.php
 *
 * @link http://code.google.com/u/kendertas/
 * @copyright 2009 KenderTas
 * @author Kender Tas <kendertas at gmail dot com>
 * @package example_page
 * @version 1.0.0
 */

define("SQLHOST","localhost");
define("SQLUSER","bbcode");
define("SQLPASS","bbcode");
define("SQLDB","bbcodeadv");

//	Includes
include("libs/class.bbCode.php");

//	this one is for DB.
include("libs/class.DB.php");
$DB	= new DB();
$conn	= $DB->SQL_Open(SQLHOST, SQLUSER, SQLPASS, SQLDB);

//	Initialize
$bbCode	= new BBCode($conn, $DB);
//	Write ControlPanel
$notShown	= array(9,10,11);
$bbCodeCP	= $bbCode->writeBBCode("KenderFormBBCode","theField",$notShown);

$content	= (isset($_REQUEST['content']) && $_REQUEST['content'] != "")	? $_REQUEST['content'] : "";
$bbCoded	= "&nbsp;";
if ($content != "")	{
	//	Convert BBCode Tags to HTML Tags
	$bbCoded	= $bbCode->parseBBCode($content);
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>BBCode Advanced Test Page</title>
	<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-5">
	<META name="Author" content="KenderThoR for More Interactive. Library version 1.1">
	<META name="keywords" content="">
	<META NAME="Description" CONTENT="">
	<link href="css/style.css" rel="stylesheet" type="text/css">
	<link href="css/thickbox.css" rel="stylesheet" type="text/css">
	<link rel="shortcut icon" href="../tpl/v1/favicon.ico" type="image/x-icon">
	<script type="text/javascript" src="js/BBCode.js"></script>
	<script type="text/javascript" src="js/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery/thickbox.js"></script>
</head>

<body>
<div align="center">
	<div style="width:780px;text-align:left;">
	<form name="KenderFormBBCode" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">

		<div style="background-color:#FAFAFA;font-size:16px;color:#333333;padding:5px;">
		<strong>BBCode Test</strong></div>
		<div style="padding:5px;"><?php echo $bbCodeCP; ?></div>
		<div style="padding:5px;"><textarea name="content" rows=10 cols=100
				class="withPadding5"
				onFocus="javascript:document.theField=this.name;"><?php echo $content; ?></textarea>
		</div><br>
		<br>
		<div style="padding:5px;">
		This content will not be parsed
		<textarea name="content2" rows=10 cols=100
				class="withPadding5"
				onFocus="javascript:document.theField=this.name;"></textarea>
		</div><br>

		<div style="padding:5px;"><input type="submit" name="go" value=" bbCode this text "></div>

	</form>
	</div>
	<br>
	<div style="width:780px;text-align:left;border:solid 1px #333333;padding:5px;">
	<?php echo $bbCoded; ?>
	</div>

</div>
</body>
</html>
